package com.cj.apiinterface;

import cn.hutool.http.server.HttpServerBase;
import com.cj.clientsdk.StringUtils;
import com.cj.clientsdk.model.User;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * @author cc
 * @date 2025-03-23 15:30
 **/
@RestController
public class UserController {

    @PostMapping("/user")
    public String getUsernameByPost(@RequestBody User user, HttpServletRequest request){
        System.out.println("user = " + user);
        String accessKey = request.getHeader("accessKey");

        String body = request.getHeader("body");
        String sign = request.getHeader("sign");

        String serverSign = StringUtils.genSign(body, "abc");
        if (!sign.equals(serverSign)){
            throw new RuntimeException("签名错误");
        }


        return "right";


    }
}
